@extends('home.home')
@section('content')
<!--content-->
<div class="blog" class="blog"  style="background: url({{asset('/images/7.jpg')}}); height:100%; width:100%;  background-attachment: fixed;">
<div class="container">
	       <div class="blog-top">
			  <div class="col-md-10 grid-1">


			        

					<h3><a href="">心情展示</a></h3>

					<a href=""><img src="{{ asset($data -> mpic) }}" class="img-responsive" alt=""/></a>
					
					<div class="blog-poast-info">
						<ul>
							<li><a class="admin" href="#" style="color:red"><i> </i> {{$data -> uname}} </a></li>
							<li><span style="color:red"><i class="date"> </i>{{$data -> regtime}}</span></li>
							<!-- <li><a class="p-blog" href="#"><i class="comment"> </i>评论</a></li> -->
						</ul>
				   
				    <p>{{$data -> idea}}</p>
				    <hr style="height:3px; background:silver;" />
				   <p style="color:gray;">评论内容 :</p>
			@foreach($res as $row)
			<div>
				   <div class="blog-poast-info">
						<ul>

                           
							<li><a class="admin" href="#" style="color:green"><i> </i> 
					
							{{$row->uname}}
							回复了：
							@if($row->pid == 0)
							
							{{$data->uname}}
							
							@else
                            {{$row->pid}}
							@endif
                
							 </a></li>
                           
							<li><span style="color:green"><i class="date"> </i>{{$row->dregtime}} </span></li>
							<li><a class="p-blog" href="#"><i class="comment"> </i>评论</a></li>
						</ul>
				    </div>
				    <p>{{$row ->comment}}</p>
				    <div class="sid" style="display: none;">{{$row->sid}}</div>
				    <div class="uid" style="display: none;">{{$row->uid}}</div>
		    </div>
		    @endforeach

				<div class="single-bottom" id="did">
				
                
		
			<h3>分享你我他  评论靠大家</h3>

			<div class="txt" style="display: none;">

			<input type="text" placeholder="回复" class="inp">

			</div>

				<form action="{{url('/home/message/update')}}" method="post" enctype="multipart/form-data">
				{{ csrf_field() }}
				<input type="hidden" name="uid" value="{{$data -> uid}}">
				<input type="hidden" name="uname" value="{{session('homeM')->uname}}">
					<input type="hidden" name="sid" value="{{session('homeM')->uid}}">

						<input type="text"  onfocus="this.value='';" onblur="if (this.value == '') {this.value ='求评论';}" name="comment">

							<input type="submit" value="评论">
							
						
				</form>
		@if(!empty($row->uid))
		 <script>
            window.onload = function()
            {
            	$.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
                //
			          $('.p-blog').on('click',function(){
		            		$('.txt').css({display:'block'});
		                   var sid = $(this).parent().parent().parent().parent().find('.sid').html();
		                   var uid = $(this).parent().parent().parent().parent().find('.uid').html();
		            var input = $('.inp');
		            input.on('blur',function(){
                    var comment = $(this).val();
                     $.ajax({
                       url:"{{url('/home/message/sAdd')}}",
                       type:'GET',
                       data:{uid:uid,pid:sid,comment:comment},
                       success:function(data){
                          if (data == 1) 
                          {
                              $('.txt').css({display:'none'});

                              location.href="{{url('/home/message/review')}}/{{$row->uid}}";
                          }
                       },
                       error:function(){

                       },
                       dataType:'TEXT'
                     });

                });

		     });	
           }    
            	

    </script>
     @endif
			</div>
			  </div>
      </div>
</div>
</div>
</div>
<!--//content-->
@endsection

			





            